class OfficeCall extends DateTracker implements Comparable {

    OfficeCallType type
    Person contact
    Representative rep
    Company company
    Date date = new Date()
    String notes

    static belongsTo= Company

    static constraints = {
        type(nullable:false)
        contact(nullable:true)
        rep(nullable:false)
        date(nullable:false)
        notes(nullable:true, maxSize:4096)
    }

    int compareTo(obj) {
        if (date.equals(obj.date)) {
            if (type.equals(obj.type)) {
                return 1
            } else {
                return type.compareTo(obj.type)
            }
        }
        obj.date.compareTo(date)
    }

    String toString() {
        "${type} ${new java.text.SimpleDateFormat("MM/dd/yyyy hh:mm").format(date)}"
    }
}
